<?php
include('config.php');
$start_ip = $_GET['ip'];
$community = "public";
$end_octet = $_GET['end_ip'];
?>

Start IP: <input id="input_start_ip" type="text" maxlength="15"/>&#160;&#160;&#160;End Octet: <input id="input_end_octet" type="text" maxlength="3"/><input type="button" value="Discover" onClick="discoverDevices(document.getElementById('input_start_ip').value, document.getElementById('input_end_octet').value);"/><br/>

<div id="device_container"></div>

<script type="text/javascript" src="scripts/mootools-1.2-core.js"></script>
<script type="text/javascript" src="scripts/mootools-1.2-more.js"></script>     

<script type="text/javascript">

function addDevice(hostname, model, ip, serial) {
	var url='pages/query.php?';
	url=url+'hostname='+hostname;
	url=url+'&model='+model;
	url=url+'&ip='+ip;
	url=url+'&serial='+serial;
	url=url+'&cmd=addDevice';
	
	//Send the data to the query.php script to update the DB
	var myRequest = new Request({
		url: url, 
		onSuccess: function(response) {
				//Disable the button if it is successful
				document.getElementById(hostname).disabled=true;
			} 
	}).send();
}

function updateDevice(hostname, model, ip, serial) {
	var url='pages/query.php?';
	url=url+'hostname='+hostname;
	url=url+'&model='+model;
	url=url+'&ip='+ip;
	url=url+'&serial='+serial;
	url=url+'&cmd=updateDevice';
	
	//Send the data to the query.php script to update the DB
	var myRequest = new Request({
		url: url, 
		onSuccess: function(response) {
				//Disable the button if it is successful
				document.getElementById(hostname).disabled=true;
			} 
	}).send();

}

function discoverDevices(start_ip, end_octet) {
	var url='pages/query.php?';
	url=url+'ip='+start_ip;
	url=url+'&end_ip='+end_octet;
	url=url+'&community=public';
	url=url+'&cmd=discoverDevices';

	var myRequest = new Request({
		url: url,
		onSuccess: function(response) {
			document.getElementById('device_container').innerHTML = response;
		}
	}).send();
}

</script>
